import java.util.ArrayList;
import java.util.List;

public class AnonymityOne {
	static List<Teacher> teacherList = new ArrayList();

	public static void main(String[] args) {
		teacherList.add(new Teacher("张三", 25));
		teacherList.add(new Teacher("李四", 29));
		teacherList.add(new Teacher("张三", 31));
		teacherList.add(new Teacher("王五", 41));
		AnonymityOne anonymityOne = new AnonymityOne();
		List<Teacher> reutrnTeacher = anonymityOne.listTeacher(new AnonymityThree() {
			@Override
			public boolean accept(Teacher teacher) {
				if (teacher.getAge() != null && teacher.getAge() > 25 && teacher.getAge()<40) {
					return true;
				}
				return false;
			}
		});
		for (Teacher tea : reutrnTeacher) {
			System.out.println(tea);
		}
	}

	public List<Teacher> listTeacher(AnonymityThree three) {
		List<Teacher> newList = new ArrayList();
		for (Teacher teacher : teacherList) {
			if (three.accept(teacher)) {
				newList.add(teacher);
			}
		}
		return newList;
	}

	public List<Teacher> listTeacher() {
		return teacherList;
	}
}
